/**
 * 
 */
package org.obiwan.subbuteo.model;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.appfuse.model.BaseObject;
import org.appfuse.model.User;

/**
 * @author ddefrancesco
 *
 */
@Entity(name="partecipante")
@Table(name="partecipante")
public class Partecipante
    extends BaseObject
{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private Long idPartecipante;
    private Set<Torneo> tornei;
    private String nomeSquadra;
    private User teamOwner;
    /**
     * @return the idPartecipante
     */
    @Id @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getIdPartecipante()
    {
        return idPartecipante;
    }
    /**
     * @return the torneo
     */
    @OneToMany(mappedBy="idTorneo", fetch=FetchType.LAZY)
    
    public Set<Torneo> getTornei()
    {
        return tornei;
    }
    /**
     * @return the nomeSquadra
     */
    @Column(name="nome_squadra", length=80)
    public String getNomeSquadra()
    {
        return nomeSquadra;
    }
    /**
     * @return the teamOwner
     */
    @ManyToOne(targetEntity=org.appfuse.model.User.class,fetch=FetchType.LAZY)
    @JoinColumn(name="teamOwner",referencedColumnName="id")
    public User getTeamOwner()
    {
        return teamOwner;
    }
    /**
     * @param idPartecipante the idPartecipante to set
     */
    public void setIdPartecipante( Long idPartecipante )
    {
        this.idPartecipante = idPartecipante;
    }
    /**
     * @param torneo the torneo to set
     */
    public void setTornei( Set<Torneo> tornei )
    {
        this.tornei = tornei;
    }
    /**
     * @param nomeSquadra the nomeSquadra to set
     */
    public void setNomeSquadra( String nomeSquadra )
    {
        this.nomeSquadra = nomeSquadra;
    }
    /**
     * @param teamOwner the teamOwner to set
     */
    public void setTeamOwner( User teamOwner )
    {
        this.teamOwner = teamOwner;
    }
    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals( final Object other )
    {
        if ( !( other instanceof Partecipante ) )
            return false;
        Partecipante castOther = (Partecipante) other;
        return new EqualsBuilder().append( idPartecipante, castOther.idPartecipante ).append( tornei, castOther.tornei ).append(nomeSquadra,castOther.nomeSquadra ).append(teamOwner,castOther.teamOwner ).isEquals();
    }
    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode()
    {
        return new HashCodeBuilder().append( idPartecipante ).append( tornei ).append( nomeSquadra ).append( teamOwner ).toHashCode();
    }
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString()
    {
        return new ToStringBuilder( this ).append( "idPartecipante", idPartecipante ).append( "tornei", tornei ).append("nomeSquadra",nomeSquadra ).append("teamOwner",teamOwner ).toString();
    } 

    
}
